package com.example.stackviewdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.StackView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    StackView stackView;
    Button btnPrev;
    Button btnNext;
    int[] imgIds = {R.drawable.img1,R.drawable.img2,R.drawable.img3,R.drawable.img4};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        stackView = findViewById(R.id.stackview);
        btnPrev = findViewById(R.id.btnPrev);
        btnNext = findViewById(R.id.btnNext);

        MyStackAdapter adapter = new MyStackAdapter(this,imgIds);
        stackView.setAdapter(adapter);
        btnPrev.setOnClickListener(this);
        btnNext.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btnPrev:
                stackView.showPrevious();
                break;
            case R.id.btnNext:
                stackView.showNext();
                break;
                default:break;
        }
    }
}
